// 合并复用原则
// Composite Reuse Principle, CRP
// 
// 这里用一个司机开车的例子来解释什么是合并复用原则
//

#pragma once

#include <iostream>

/// @brief 假设有宝马车开
class BMW 
{
public:
	BMW() = default;
	virtual ~BMW() {}

	virtual void run() {
		std::cout << "drive " << name << " car." << std::endl;
	}

private:
	std::string name = "BMW";

};

/// @brief 假设有大众车开
class Volkswagen
{
public:
	Volkswagen() = default;
	virtual ~Volkswagen() {}

	virtual void run() {
		std::cout << "drive " << name << " car." << std::endl;
	}

private:
	std::string name = "Volkswagen";

};

/// @brief 司机类
class Drivers
// 司机想要开多种车咋办呢？
//
{
public:
	Drivers() = default;
	~Drivers() = default;

    void driveBMW() {
        m_bmw.run();
    }

    void driveVolkswagen() {
        m_volkswagen.run();
    }

private:
	BMW m_bmw;
    Volkswagen m_volkswagen;
};
